home *** CD-ROM | disk | FTP | other *** search
/ PD Collection CD 1 / PD Collection CD 1.iso / programer2 / lisp / clisp / !Clisp_txt_impnotes < prev    next >
Encoding:
Text File  |  1995-01-03  |  69.6 KB  |  1,943 lines

  1.                 Implementation Notes for CLISP
  2.                 ==============================
  3.                 Last modified: 8 December 1994.
  4.  
  5. This implementation is mostly compatible to the standard reference
  6.  
  7.        Guy L. Steele Jr.: Common Lisp - The Language (1st ed.).
  8.        Digital Press 1984, 465 pages.
  9.        ("CLtL1" for short)
  10.  
  11. and to the older parts of
  12.  
  13.        Guy L. Steele Jr.: Common Lisp - The Language (2nd ed.).
  14.        Digital Press 1990, 1032 pages.
  15.        ("CLtL2" for short)
  16.  
  17.  
  18. These notes document the differences of the CLISP implementation of Common
  19. Lisp to the standard CLtL1, and some implementation details.
  20.  
  21. The differences between CLtL1 and CLtL2 are made up of X3J13 votes. CLISP's
  22. position with respect to these votes is listed in cltl2.txt.
  23.  
  24.  
  25.                       CHAPTER 1: Introduction
  26.                       -----------------------
  27.  
  28. No notes.
  29.  
  30.  
  31.                        CHAPTER 2: Data Types
  32.                        ---------------------
  33.  
  34. All the data types are implemented: numbers, characters, symbols, lists,
  35. arrays, hash tables, readtables, packages, pathnames, streams, random
  36. states, structures and functions.
  37.  
  38. 2.1.3.
  39. ------
  40.  
  41. There are four floating point types: short-float, single-float, double-float
  42. and long-float:
  43.                   sign    mantissa   exponent
  44.    short-float    1 bit   16+1 bits   8 bits
  45.    single-float   1 bit   23+1 bits   8 bits   CLISP uses IEEE format
  46.    double-float   1 bit   52+1 bits  11 bits   CLISP uses IEEE format
  47.    long-float     1 bit   >=64 bits  32 bits
  48.  
  49. The single and double float formats are those of the IEEE standard (1981),
  50. except that CLISP does not support features like +0, -0, +inf, -inf, gradual
  51. underflow, NaN, etc. (Common Lisp does not make use of these features.)
  52.  
  53. Long floats have variable mantissa length, which is a multiple of 16 (or 32,
  54. depending on the word size of the processor). The default length used when
  55. long floats are read is given by the place (LONG-FLOAT-DIGITS). It can be
  56. set by (SETF (LONG-FLOAT-DIGITS) nnn), where nnn is a positive integer.
  57.  
  58. 2.1.4.
  59. ------
  60.  
  61. Complex numbers can have a real part and an imaginary part of different
  62. types. For example, (SQRT -9.0) evaluates to the number #C(0 3.0), which has
  63. a real part of exactly 0, not only 0.0 (which would mean "approximately 0").
  64. The type specifier for this is (COMPLEX INTEGER SINGLE-FLOAT), and
  65.  
  66.            (COMPLEX type-of-real-part type-of-imaginary-part)
  67.  
  68. in general.
  69. The type specifier (COMPLEX type) is equivalent to (COMPLEX type type).
  70.  
  71. 2.2.1.
  72. ------
  73.  
  74. The characters are ordered according to the ASCII encoding.
  75.  
  76. More precisely, CLISP uses the ISO Latin-1 (ISO 8859-1) character set:
  77.              $0 $1 $2 $3 $4 $5 $6 $7 $8 $9 $A $B $C $D $E $F
  78.          $00 ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** **
  79.          $10 ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** **
  80.          $20     !  "  #  $  %  &  '  (  )  *  +  ,  -  .  /
  81.          $30  0  1  2  3  4  5  6  7  8  9  :  ;  <  =  >  ?
  82.          $40  @  A  B  C  D  E  F  G  H  I  J  K  L  M  N  O
  83.          $50  P  Q  R  S  T  U  V  W  X  Y  Z  [  \  ]  ^  _
  84.          $60  `  a  b  c  d  e  f  g  h  i  j  k  l  m  n  o
  85.          $70  p  q  r  s  t  u  v  w  x  y  z  {  |  }  ~   
  86.          $80                                                
  87.          $90                                                
  88.          $A0     ¡  ¢  £  ¤  ¥  ¦  §  ¨  ©  ª  «  ¬  ­  ®  ¯
  89.          $B0  °  ±  ²  ³  ´  µ  ¶  ·  ¸  ¹  º  »  ¼  ½  ¾  ¿
  90.          $C0  À  Á  Â  Ã  Ä  Å  Æ  Ç  È  É  Ê  Ë  Ì  Í  Î  Ï
  91.          $D0  Ð  Ñ  Ò  Ó  Ô  Õ  Ö  ×  Ø  Ù  Ú  Û  Ü  Ý  Þ  ß
  92.          $E0  à  á  â  ã  ä  å  æ  ç  è  é  ê  ë  ì  í  î  ï
  93.          $F0  ð  ñ  ò  ó  ô  õ  ö  ÷  ø  ù  ú  û  ü  ý  þ  ÿ
  94. Here ** are control characters, not graphic characters. (The characters left
  95. blank here cannot be represented in this character set).
  96.  
  97. The following are standard characters:
  98.   #\Space               $20
  99.   #\Newline             $0A
  100. The following are semi-standard characters:
  101.   #\Backspace           $08
  102.   #\Tab                 $09
  103.   #\Linefeed            $0A
  104.   #\Page                $0C
  105.   #\Return              $0D
  106.   #\Rubout              $7F
  107.  
  108. 2.2.2.
  109. ------
  110.  
  111. #\Newline is the delimiter between lines.
  112.  
  113. When reading from a file, CR/LF is converted to #\Newline, and CR not
  114. followed by LF is read as #\Return.
  115.  
  116. 2.2.3.
  117. ------
  118.  
  119. There are the following additional characters with names:
  120.   #\Null                $00
  121.   #\Bell                $07
  122.   #\Escape              $1B
  123.  
  124. 2.2.4.
  125. ------
  126.  
  127. The code of a character is >=0, <256. CHAR-CODE-LIMIT = 256.
  128.  
  129. There are fonts 0 to 15, and CHAR-FONT-LIMIT = 16. But the system itself
  130. uses only font 0.
  131.  
  132. The following bits attributes are implemented: :CONTROL, :META, :SUPER,
  133. :HYPER. Therefore CHAR-BITS-LIMIT = 16.
  134. The system itself uses these bits only to mention special keys and
  135. Control/Alternate/Shift key status on return from
  136. (READ-CHAR *KEYBOARD-INPUT*).
  137.  
  138. 2.5.
  139. ----
  140.  
  141. The maximum rank (number of dimensions) of an array is 65535 on 16-bit
  142. processors, 4294967295 on 32-bit processors.
  143.  
  144. 2.13.
  145. -----
  146.  
  147. All the functions built by FUNCTION, COMPILE and the like are atoms. There
  148. are built-in functions written in C, compiled functions (both of type
  149. COMPILED-FUNCTION) and interpreted functions (of type FUNCTION).
  150. The possible function names (CLtL1 p. 59) are symbols and lambda expressions.
  151.  
  152. 2.14.
  153. -----
  154.  
  155. This is the list of objects whose external representation can not be
  156. meaningfully read in:
  157.   * all structures lacking a keyword constructor.
  158.   * all arrays except strings, if *PRINT-ARRAY* = NIL.
  159.   * #<SYSTEM-FUNCTION name>     built-in function written in C
  160.   * #<FOREIGN-FUNCTION name>    other function written in C
  161.   * #<SPECIAL-FORM name>        special form handler
  162.   * #<COMPILED-CLOSURE name>    compiled function, if *PRINT-CLOSURE* = NIL
  163.   * #<CLOSURE name ...>         interpreted function
  164.   * #<FRAME-POINTER #x...>      pointer to a stack frame
  165.   * #<DISABLED POINTER>         frame pointer which has become invalid on
  166.                                 exit from the corresponding BLOCK or TAGBODY
  167.   * #<...-STREAM ...>           stream
  168.   * #<PACKAGE name>             package
  169.   * #<HASH-TABLE #x...>         hash table, if *PRINT-ARRAY* = NIL
  170.   * #<READTABLE #x...>          readtable
  171.   * #<UNBOUND>                  "value" of a symbol without value, "value"
  172.                                 of an unsupplied optional or keyword argument
  173.   * #<SPECIAL REFERENCE>        environment marker for variables declared
  174.                                 SPECIAL
  175.   * #<DOT>                      internal READ result for "."
  176.   * #<END OF FILE>              internal READ result, when the end of file
  177.                                 is reached
  178.   * #<READ-LABEL ...>           intermediate READ result for #n#
  179.   * #<ADDRESS #x...>            machine address, should not occur
  180.   * #<SYSTEM-POINTER #x...>     should not occur
  181.  
  182. 2.15.
  183. -----
  184.  
  185. The type NUMBER is the disjoint union of the types REAL and COMPLEX. (CLtL
  186. wording: "exhaustive partition")
  187. The type REAL is the disjoint union of the types RATIONAL and FLOAT.
  188. The type RATIONAL is the disjoint union of the types INTEGER and RATIO.
  189. The type INTEGER is the disjoint union of the types FIXNUM and BIGNUM.
  190. The type FLOAT is the disjoint union of the types SHORT-FLOAT, SINGLE-FLOAT,
  191. DOUBLE-FLOAT and LONG-FLOAT.
  192.  
  193.  
  194.                      CHAPTER 3: Scope and Extent
  195.                      ---------------------------
  196.  
  197. is implemented as described.
  198.  
  199.  
  200.                       CHAPTER 4: Type Specifiers
  201.                       --------------------------
  202.  
  203. 4.4.
  204. ----
  205.  
  206. The CLtL2 type specifier (EQL object) denotes the singleton set {object}.
  207.  
  208. 4.5.
  209. ----
  210.  
  211. The general form of the COMPLEX type specifier is
  212. (COMPLEX type-of-real-part type-of-imaginary-part).
  213. The type specifier (COMPLEX type) is equivalent to (COMPLEX type type).
  214.  
  215. 4.6.
  216. ----
  217.  
  218. The CLtL2 type specifier (REAL low high) denotes the real numbers between low
  219. and high.
  220.  
  221. 4.7.
  222. ----
  223.  
  224. DEFTYPE lambda lists are subject to destructuring (nested lambda lists are
  225. allowed, as in DEFMACRO) and may contain a &WHOLE marker, but no
  226. &ENVIRONMENT marker.
  227.  
  228. 4.9.
  229. ----
  230.  
  231. The possible results of TYPE-OF are:
  232.  CONS
  233.  SYMBOL NULL
  234.  FIXNUM BIGNUM RATIO SHORT-FLOAT SINGLE-FLOAT DOUBLE-FLOAT LONG-FLOAT COMPLEX
  235.  CHARACTER
  236.  (ARRAY element-type dimensions), (SIMPLE-ARRAY element-type dimensions)
  237.  (VECTOR T size), (SIMPLE-VECTOR size)
  238.  (STRING size), (SIMPLE-STRING size)
  239.  (BIT-VECTOR size), (SIMPLE-BIT-VECTOR size)
  240.  FUNCTION COMPILED-FUNCTION
  241.  STREAM PACKAGE HASH-TABLE READTABLE PATHNAME LOGICAL-PATHNAME RANDOM-STATE
  242.  BYTE LOAD-TIME-EVAL SYMBOL-MACRO READ-LABEL FRAME-POINTER SYSTEM-INTERNAL
  243.  ADDRESS (should not occur)
  244.  any other symbol (structure types or CLOS classes)
  245.  a class (CLOS classes without proper name)
  246.  
  247.  
  248.                        CHAPTER 5: Program Structure
  249.                        ----------------------------
  250.  
  251. 5.1.3.
  252. ------
  253.  
  254. In addition to the 24 special forms listed on p. 57 (CLtL2: p. 73), the
  255. CLtL2 special forms LOCALLY, SYMBOL-MACROLET, LOAD-TIME-VALUE are implemented,
  256. and the macros
  257. PSETQ, PROG1, PROG2, WHEN, UNLESS, COND, MULTIPLE-VALUE-LIST,
  258. MULTIPLE-VALUE-BIND, MULTIPLE-VALUE-SETQ, AND, OR
  259. are implemented as special forms.
  260.  
  261. Constants may not be bound dynamically or lexically.
  262.  
  263. 5.2.2.
  264. ------
  265.  
  266. LAMBDA-LIST-KEYWORDS =
  267.     (&OPTIONAL &REST &KEY &ALLOW-OTHER-KEYS &AUX &BODY &WHOLE &ENVIRONMENT)
  268.  
  269. LAMBDA-PARAMETERS-LIMIT is 65536 on 16-bit processors, 4294967296 on 32-bit
  270. processors.
  271.  
  272. 5.3.
  273. ----
  274.  
  275. DEFUN and DEFMACRO are allowed in non-toplevel positions.
  276. As an example, consider the definition of GENSYM:
  277. (let ((gensym-prefix "G")
  278.       (gensym-count 1))
  279.   (defun gensym (&optional (x nil s))
  280.     (when s
  281.       (cond ((stringp x) (setq gensym-prefix x))
  282.             ((integerp x)
  283.              (if (minusp x)
  284.                (error "~S: index ~S is negative" 'gensym x)
  285.                (setq gensym-count x)
  286.             ))
  287.             (t (error "~S: argument ~S of wrong type" 'gensym x))
  288.     ) )
  289.     (prog1
  290.       (make-symbol
  291.         (concatenate 'string
  292.           gensym-prefix
  293.           (write-to-string gensym-count :base 10 :radix nil)
  294.       ) )
  295.       (incf gensym-count)
  296. ) )
  297.  
  298. 5.3.2.
  299. ------
  300.  
  301. (PROCLAIM '(SPECIAL var)) declarations may not be undone. The same holds
  302. for DEFVAR, DEFPARAMETER and DEFCONSTANT declarations.
  303.  
  304. It is an error if a DEFCONSTANT variable is bound at the moment the
  305. DEFCONSTANT is executed, but DEFCONSTANT does not check this.
  306.  
  307. Constants may not be bound dynamically or lexically.
  308.  
  309. 5.3.3.
  310. ------
  311.  
  312. EVAL-WHEN also accepts the situations (NOT EVAL) and (NOT COMPILE).
  313.  
  314.  
  315.                       CHAPTER 6: Predicates
  316.                       ---------------------
  317.  
  318. 6.2.2.
  319. ------
  320.  
  321. REALP returns T is its argument is a real number, NIL otherwise.
  322.  
  323. COMPILED-FUNCTION-P returns T on built-in functions written in C, compiled
  324. functions and special form handlers. Therefore COMPILED-FUNCTION is not a
  325. subtype of FUNCTION.
  326.  
  327. 6.3.
  328. ----
  329.  
  330. EQ compares characters and fixnums as EQL does. No unnecessary copies are
  331. made of characters and numbers. Nevertheless, one should use EQL.
  332.  
  333. (let ((x y)) (eq x x)) always returns T, regardless of y.
  334.  
  335. 6.4.
  336. ----
  337.  
  338. AND and OR are implemented as special forms and, as such, rather efficient.
  339.  
  340.  
  341.                       CHAPTER 7: Control Structure
  342.                       ----------------------------
  343.  
  344. 7.1.1.
  345. ------
  346.  
  347. (FUNCTION symbol) returns the local function definition established by FLET
  348. or LABELS, if it exists, otherwise the global function definition.
  349.  
  350. The CLtL2 place (FDEFINITION function-name) is implemented.
  351.  
  352. (SPECIAL-FORM-P symbol) returns NIL or T. If it returns T, then
  353. (SYMBOL-FUNCTION symbol) returns the (useless) special form handler.
  354.  
  355. 7.1.2.
  356. ------
  357.  
  358. PSETQ is implemented as a special form and, as such, rather efficient.
  359.  
  360. 7.2.
  361. ----
  362.  
  363. (SETF (SYMBOL-FUNCTION symbol) object) requires object to be either a
  364. function, a SYMBOL-FUNCTION return value or a lambda expression. A lambda
  365. expression is thereby immediately converted to a function.
  366.  
  367. SETF also accepts places yielding multiple values.
  368.  
  369. Additional places:
  370.  
  371. * FUNCALL:
  372.   (SETF (FUNCALL #'symbol ...) object) and
  373.   (SETF (FUNCALL 'symbol ...) object)
  374.   are equivalent to (SETF (symbol ...) object).
  375.  
  376. * GET-DISPATCH-MACRO-CHARACTER:
  377.   (SETF (GET-DISPATCH-MACRO-CHARACTER ...) ...)
  378.   performs a SET-DISPATCH-MACRO-CHARACTER.
  379.  
  380. * LONG-FLOAT-DIGITS:
  381.   (SETF (LONG-FLOAT-DIGITS) digits) sets the default mantissa length of long
  382.   floats to digits bits.
  383.  
  384. * VALUES:
  385.   (SETF (VALUES place1 ... placek) form)
  386.   is approximately equivalent to
  387.      (MULTIPLE-VALUE-BIND (dummy1 ... dummyk) form
  388.        (SETF place1 dummy1 ... placek dummyk)
  389.        (VALUES dummy1 ... dummyk)
  390.      )
  391.   Example:
  392.     (SETF (VALUES A B) (VALUES B A)) interchanges the values of A and B.
  393.  
  394. * VALUES-LIST:
  395.   (SETF (VALUES-LIST list) form)  is equivalent to
  396.   (VALUES-LIST (SETF list (MULTIPLE-VALUE-LIST form)))
  397.  
  398. &KEY markers in DEFSETF lambda lists are supported, but the corresponding
  399. keywords must appear literally in the program text.
  400.  
  401. (GET-SETF-METHOD form &optional env) and
  402. (GET-SETF-METHOD-MULTIPLE-VALUE form &optional env)
  403. receives as optional argument the environment necessary for macro expansions.
  404. In DEFINE-SETF-METHOD lambda lists, one can specify &ENVIRONMENT and a
  405. variable, which will be bound to the environment. This environment should be
  406. passed to all calls of GET-SETF-METHOD and GET-SETF-METHOD-MULTIPLE-VALUE.
  407. If this is done, even local macros will be interpreted as places correctly.
  408.  
  409. 7.3.
  410. ----
  411.  
  412. CALL-ARGUMENTS-LIMIT is 65536 on 16-bit processors, 4294967296 on 32-bit
  413. processors.
  414.  
  415. 7.4.
  416. ----
  417.  
  418. PROG1 and PROG2 are implemented as special forms and, as such, rather
  419. efficient.
  420.  
  421. 7.5.
  422. ----
  423.  
  424. The CLtL2 special form SYMBOL-MACROLET is implemented.
  425.  
  426. The macro DEFINE-SYMBOL-MACRO establishes symbol macros with global scope
  427. (as opposed to symbol macros defined with SYMBOL-MACROLET, which have local
  428. scope): (DEFINE-SYMBOL-MACRO symbol expansion). Calling BOUNDP, SYMBOL-VALUE
  429. or MAKUNBOUND on symbols defined as symbol macros is not allowed.
  430.  
  431. If using the optional package MACROS3:
  432.   The macros LETF and LETF* are like LET and LET*, resp., except that they
  433.   can bind places, even places with multiple values.
  434.   Example:
  435.   (LETF (((VALUES A B) form)) ...)
  436.     is equivalent to
  437.     (MULTIPLE-VALUE-BIND (A B) form ...)
  438.   (LETF (((FIRST L) 7)) ...)
  439.     is approximately equivalent to
  440.     (LET* ((#:G1 L) (#:G2 (FIRST #:G1)))
  441.       (UNWIND-PROTECT (PROGN (SETF (FIRST #:G1) 7) ...)
  442.                       (SETF (FIRST #:G1) #:G2)
  443.     ) )
  444.  
  445. 7.6.
  446. ----
  447.  
  448. WHEN, UNLESS, COND are implemented as special forms and, as such, rather
  449. efficient.
  450.  
  451. 7.8.4.
  452. ------
  453.  
  454. The function MAPCAP is like MAPCAN, except that it concatenates the
  455. resulting lists with APPEND instead of NCONC:
  456.   (MAPCAP fun x1 ... xn) == (apply #'append (mapcar fun x1 ... xn))
  457. (Actually a bit more efficient that this would be.)
  458.  
  459. The function MAPLAP is like MAPCON, except that it concatenates the
  460. resulting lists with APPEND instead of NCONC:
  461.   (MAPLAP fun x1 ... xn) = (apply #'append (maplist fun x1 ... xn))
  462. (Actually a bit more efficient that this would be.)
  463.  
  464. 7.9.1.
  465. ------
  466.  
  467. MULTIPLE-VALUES-LIMIT = 128
  468.  
  469. MULTIPLE-VALUE-LIST, MULTIPLE-VALUE-BIND, MULTIPLE-VALUE-SETQ are
  470. implemented as special forms and, as such, rather efficient.
  471.  
  472. The macro NTH-VALUE:
  473. (NTH-VALUE n form) returns the (n+1)st value (n>=0) of form.
  474.  
  475.  
  476.                         CHAPTER 8: Macros
  477.                         -----------------
  478.  
  479. 8.3.
  480. ----
  481.  
  482. The CLtL2 macro DESTRUCTURING-BIND is implemented. It does not perform full
  483. error checking.
  484.  
  485.  
  486.                      CHAPTER 9: Declarations
  487.                      -----------------------
  488.  
  489. 9.1.
  490. ----
  491.  
  492. The CLtL2 macro DECLAIM is implemented.
  493.  
  494. 9.2.
  495. ----
  496.  
  497. The declarations (TYPE type var ...), (FTYPE type fun ...),
  498. (FUNCTION name arglist result-type), (OPTIMIZE (quality value) ...)
  499. are ignored by the interpreter and the compiler.
  500.  
  501. The CLtL2 declaration (OPTIMIZE (DEBUG ...)) is legal.
  502.  
  503. Additional declarations:
  504.  
  505. * The declaration (COMPILE) has the effect that the current form is compiled
  506.   prior to execution.
  507.   Examples:
  508.   (LOCALLY (DECLARE (COMPILE)) form)
  509.   executes a compiled version of form.
  510.   (let ((x 0))
  511.     (flet ((inc () (declare (compile)) (incf x))
  512.            (dec () (decf x)))
  513.       (values #'inc #'dec)
  514.   ) )
  515.   returns two functions. The first is compiled and increments x, the second
  516.   is interpreted (slower) and decrements the same x.
  517.  
  518. 9.3.
  519. ----
  520.  
  521. The type assertion (THE value-type form) enforces a type check in
  522. interpreted code. No type check is done in compiled code.
  523.  
  524. If using the optional package MACROS3:
  525. (ETHE value-type form) enforces a type check in both interpreted and
  526. compiled code.
  527.  
  528.  
  529.                          CHAPTER 10: Symbols
  530.                          -------------------
  531.  
  532. No notes.
  533.  
  534.  
  535.                          CHAPTER 11: Packages
  536.                          --------------------
  537.  
  538. 11.6.
  539. -----
  540.  
  541. The package SYSTEM has the nicknames "SYS" and, additionally, "COMPILER".
  542.  
  543. The CLtL2 packages
  544. * COMMON-LISP with nickname "CL" and
  545. * COMMON-LISP-USER with nickname "CL-USER"
  546. are implemented. The package COMMON-LISP exports only those symbols
  547. from the proposed ANSI CL draft that are actually implemented.
  548.  
  549. 11.7.
  550. -----
  551.  
  552. The CLtL2 macro DEFPACKAGE is implemented.
  553.  
  554. 11.8.
  555. -----
  556.  
  557. The function REQUIRE receives as optional argument either a pathname or a
  558. list of pathnames: files to be loaded if the required module is not already
  559. in memory.
  560.  
  561.  
  562.                            CHAPTER 12: Numbers
  563.                            -------------------
  564.  
  565. The single and double float formats are those of the IEEE standard (1981),
  566. except that CLISP does not support features like +0, -0, +inf, -inf, gradual
  567. underflow, NaN, etc. (Common Lisp does not make use of these features.)
  568.  
  569. The default number of mantissa bits in long floats is given by the place
  570. (LONG-FLOAT-DIGITS).
  571. Example: (SETF (LONG-FLOAT-DIGITS) 3322) sets the default precision of long
  572. floats to 1000 decimal digits.
  573.  
  574. 12.1.
  575. -----
  576.  
  577. Complex numbers can have a real part and an imaginary part of different
  578. types. If the imaginary part is EQL to 0, the number is automatically
  579. converted to a real number. (Cf. CLtL1 p. 195)
  580. This has the advantage that  (let ((x (sqrt -9.0))) (* x x))
  581. - instead of evaluting to #C(-9.0 0.0), with x = #C(0.0 3.0) -
  582. evaluates to #C(-9.0 0) = -9.0, with x = #C(0 3.0).
  583.  
  584. Coercions on operations involving different types:
  585. The result of an arithmetic operation whose arguments are of different float
  586. types is rounded to the float format of the shortest (least precise) of the
  587. arguments.
  588.     rational -> long float -> double float -> single float -> short float
  589. (in contrast to CLtL1 p. 195!)
  590. Rationale:
  591.   See it mathematically. Add intervals:
  592.   {1.0 +/- 1e-8} + {1.0 +/- 1e-16} = {2.0 +/- 1e-8}
  593.   So, if we add 1.0s0 and 1.0d0, we should get 2.0s0.
  594. Shortly:
  595.   Do not suggest accuracy of a result by giving it a precision that is
  596.   greater than its accuracy.
  597. Example:
  598.   (- (+ 1.7 pi) pi)  should not return  1.700000726342836417234L0,
  599.   it should return 1.7f0 (or 1.700001f0 if there were rounding errors).
  600. Experience:
  601.   If in a computation using thousands of short floats, a long float (like pi)
  602.   happens to be used, the long precision should not propagate throughout all
  603.   the intermediate values. Otherwise, the long result would look precise,
  604.   but its accuracy is only that of a short float; furthermore much
  605.   computation time would be lost by calculating with long floats when only
  606.   short floats would be needed.
  607.  
  608. When rational numbers are to be converted to floats (due to FLOAT, COERCE,
  609. SQRT or a transcendental function), the result type is given by the variable
  610. *DEFAULT-FLOAT-FORMAT*.
  611.  
  612. The macro WITHOUT-FLOATING-POINT-UNDERFLOW:
  613.   (without-floating-point-underflow {form}*)
  614. executes the forms, with errors of type FLOATING-POINT-UNDERFLOW inhibited.
  615. Floating point operations will silently return zero instead of signalling
  616. an error of type FLOATING-POINT-UNDERFLOW.
  617.  
  618. 12.4.
  619. -----
  620.  
  621. (LCM), called without arguments, returns 1, which is the neutral element of
  622. composition with LCM.
  623.  
  624. (! n) returns the factorial of n, n a nonnegative integer.
  625.  
  626. (EXQUO x y) returns the quotient x/y of two integers x,y, and checks that it
  627. is an integer. (This is more efficient than /.)
  628.  
  629. (XGCD x1 ... xn) returns the values g, c1, ..., cn, where
  630. g is the greatest common divisor of the integers x1,...,xn,
  631. and c1,...,cn are integer coefficients such that
  632.   g = (GCD x1 ... xn) = (+ (* c1 x1) ... (* cn xn))
  633.  
  634. 12.5.1.
  635. -------
  636.  
  637. (EXPT base exponent) is not very precise if exponent has large absolute
  638. value.
  639.  
  640. (LOG number base) signals an error if base = 1.
  641.  
  642. 12.5.2.
  643. -------
  644.  
  645. The value of PI is a long float with the precision given by
  646. (LONG-FLOAT-DIGITS). When this precision is changed, the value of PI is
  647. automatically recomputed. Therefore PI is a variable, not a constant.
  648.  
  649. 12.6.
  650. -----
  651.  
  652. FLOAT-RADIX always returns 2.
  653.  
  654. (FLOAT-DIGITS number digits) coerces `number' (a real number) to a floating
  655. point number with at least `digits' mantissa digits. The following holds:
  656.    (>= (FLOAT-DIGITS (FLOAT-DIGITS number digits)) digits)
  657.  
  658. 12.7.
  659. -----
  660.  
  661. BOOLE-CLR   =  0
  662. BOOLE-SET   = 15
  663. BOOLE-1     = 10
  664. BOOLE-2     = 12
  665. BOOLE-C1    =  5
  666. BOOLE-C2    =  3
  667. BOOLE-AND   =  8
  668. BOOLE-IOR   = 14
  669. BOOLE-XOR   =  6
  670. BOOLE-EQV   =  9
  671. BOOLE-NAND  =  7
  672. BOOLE-NOR   =  1
  673. BOOLE-ANDC1 =  4
  674. BOOLE-ANDC2 =  2
  675. BOOLE-ORC1  = 13
  676. BOOLE-ORC2  = 11
  677.  
  678. 12.10.
  679. ------
  680.  
  681. MOST-POSITIVE-FIXNUM = 2^24-1 = 16777215
  682. MOST-NEGATIVE-FIXNUM = -2^24 = -16777216
  683.  
  684. Together with PI, the other long float constants MOST-POSITIVE-LONG-FLOAT,
  685. LEAST-POSITIVE-LONG-FLOAT, LEAST-NEGATIVE-LONG-FLOAT,
  686. MOST-NEGATIVE-LONG-FLOAT, LONG-FLOAT-EPSILON, LONG-FLOAT-NEGATIVE-EPSILON
  687. are recomputed whenever (LONG-FLOAT-DIGITS) is changed. They are variables,
  688. not constants.
  689.  
  690.  
  691.                          CHAPTER 13: Characters
  692.                          ----------------------
  693.  
  694. See first above: 2.2.
  695.  
  696. 13.1.
  697. -----
  698.  
  699. CHAR-CODE-LIMIT = 256
  700. CHAR-FONT-LIMIT = 16
  701. CHAR-BITS-LIMIT = 16
  702.  
  703. 13.2.
  704. -----
  705.  
  706. String-chars are those characters with font = 0 and bits = 0.
  707.  
  708. The graphic characters have been described above.
  709.  
  710. The standard characters are #\Newline and those graphic characters with a
  711. code between 32 and 126 (inclusive).
  712.  
  713. The alphabetic characters are these string-chars:
  714.              ABCDEFGHIJKLMNOPQRSTUVWXYZ
  715.              abcdefghijklmnopqrstuvwxyz
  716. and the international alphabetic characters from the character set:
  717.              ÇüéâäàåçêëèïîìÄÅÉæÆôöòûùÿÖÜßáíóúñѪºãõØøÀÃÕ etc.
  718.  
  719. The functions CHAR-EQUAL, CHAR-NOT-EQUAL, CHAR-LESSP, CHAR-GREATERP,
  720. CHAR-NOT-GREATERP, CHAR-NOT-LESSP ignore bits and font attributes of their
  721. arguments.
  722.  
  723. 13.4.
  724. -----
  725.  
  726. The string chars that are not graphic chars and the space character have
  727. names:
  728.   (code-char #x00) = #\Null = #\Nul
  729.   (code-char #x01) = #\Soh
  730.   (code-char #x02) = #\Stx
  731.   (code-char #x03) = #\Etx
  732.   (code-char #x04) = #\Eot
  733.   (code-char #x05) = #\Enq
  734.   (code-char #x06) = #\Ack
  735.   (code-char #x07) = #\Bell = #\Bel
  736.   (code-char #x08) = #\Backspace = #\Bs
  737.   (code-char #x09) = #\Tab = #\Ht
  738.   (code-char #x0A) = #\Newline = #\Nl = #\Linefeed
  739.   (code-char #x0B) = #\Vt
  740.   (code-char #x0C) = #\Page = #\Np
  741.   (code-char #x0D) = #\Return = #\Cr
  742.   (code-char #x0E) = #\So
  743.   (code-char #x0F) = #\Si
  744.   (code-char #x10) = #\Dle
  745.   (code-char #x11) = #\Dc1
  746.   (code-char #x12) = #\Dc2
  747.   (code-char #x13) = #\Dc3
  748.   (code-char #x14) = #\Dc4
  749.   (code-char #x15) = #\Nak
  750.   (code-char #x16) = #\Syn
  751.   (code-char #x17) = #\Etb
  752.   (code-char #x18) = #\Can
  753.   (code-char #x19) = #\Em
  754.   (code-char #x1A) = #\Sub
  755.   (code-char #x1B) = #\Escape = #\Esc
  756.   (code-char #x1C) = #\Fs
  757.   (code-char #x1D) = #\Gs
  758.   (code-char #x1E) = #\Rs
  759.   (code-char #x1F) = #\Us
  760.   (code-char #x20) = #\Space = #\Sp
  761.   (code-char #x7F) = #\Rubout = #\Delete = #\Del
  762.  
  763. 13.5.
  764. -----
  765.  
  766. CHAR-CONTROL-BIT = 1
  767. CHAR-META-BIT    = 2
  768. CHAR-SUPER-BIT   = 4
  769. CHAR-HYPER-BIT   = 8
  770.  
  771.  
  772.                          CHAPTER 14: Sequences
  773.                          ---------------------
  774.  
  775. 14.1.
  776. -----
  777.  
  778. The result of NREVERSE is always EQ to the argument. NREVERSE on a vector
  779. swaps pairs of elements. NREVERSE on a list swaps the first and the last
  780. element and reverses the list chaining between them.
  781.  
  782. 14.2.
  783. -----
  784.  
  785. For iteration through a sequence, a macro DOSEQ, analogous to DOLIST, may be
  786. used instead of MAP :
  787.   (doseq (var seqform [resultform]) {declaration}* {tag|statement}* )
  788.  
  789. The CLtL2 function MAP-INTO is implemented.
  790.  
  791. 14.3.
  792. -----
  793.  
  794. REMOVE, REMOVE-IF, REMOVE-IF-NOT, REMOVE-DUPLICATES return their argument
  795. unchanged, if no element has to be removed.
  796.  
  797. DELETE, DELETE-IF, DELETE-IF-NOT, DELETE-DUPLICATES destructively modify
  798. their argument: If the argument is a list, the CDR parts are modified. If
  799. the argument is a vector with fill pointer, the fill pointer is lowered and
  800. the remaining elements are compacted below the new fill pointer.
  801.  
  802. 14.5.
  803. -----
  804.  
  805. SORT and STABLE-SORT have two additional keywords :START and :END :
  806.   (SORT sequence predicate &key :key :start :end)
  807.   (STABLE-SORT sequence predicate &key :key :start :end)
  808.  
  809. SORT and STABLE-SORT are identical. They implement the mergesort algorithm.
  810.  
  811.  
  812.                          CHAPTER 15: Lists
  813.                          -----------------
  814.  
  815. 15.4.
  816. -----
  817.  
  818. SUBLIS and NSUBLIS apply the :KEY argument to the nodes of the cons tree and
  819. not to the keys of the alist.
  820.  
  821.  
  822.                       CHAPTER 16: Hash Tables
  823.                       -----------------------
  824.  
  825. 16.1.
  826. -----
  827.  
  828. MAKE-HASH-TABLE has an additional keyword :INITIAL-CONTENTS :
  829.   (MAKE-HASH-TABLE &key :test :initial-contents :size :rehash-size
  830.                         :rehash-threshold)
  831. The :INITIAL-CONTENTS argument is an alist that is used to initialize the
  832. new hash table.
  833. The :REHASH-THRESHOLD argument is ignored.
  834.  
  835. For iteration through a hash table, a macro DOHASH, analogous to DOLIST, can
  836. be used instead of MAPHASH :
  837.   (dohash (key-var value-var hash-table-form [resultform])
  838.     {declaration}* {tag|statement}*
  839.   )
  840.  
  841.  
  842.                      CHAPTER 17: Arrays
  843.                      ------------------
  844.  
  845. 17.1.
  846. -----
  847.  
  848. MAKE-ARRAY can return specialized arrays for the element types
  849. (UNSIGNED-BYTE 2), (UNSIGNED-BYTE 4), (UNSIGNED-BYTE 8), (UNSIGNED-BYTE 16),
  850. (UNSIGNED-BYTE 32) and of course BIT and STRING-CHAR.
  851.  
  852. ARRAY-RANK-LIMIT is 65536 on 16-bit processors, 4294967296 on 32-bit
  853. processors.
  854.  
  855. ARRAY-DIMENSION-LIMIT  = 2^24 = 16777216
  856. ARRAY-TOTAL-SIZE-LIMIT = 2^24 = 16777216
  857.  
  858. 17.6.
  859. -----
  860.  
  861. An array to which another array is displaced should not be shrunk (using
  862. ADJUST-ARRAY) in such a way that the other array points into void space.
  863. This is not checked at the time ADJUST-ARRAY is called!
  864.  
  865.  
  866.                        CHAPTER 18: Strings
  867.                        -------------------
  868.  
  869. 18.2.
  870. -----
  871.  
  872. String comparison is based on the function CHAR<=. Therefore diphtongs do
  873. not obey the usual national rules. Example: "o" < "oe" < "z" < "ö".
  874.  
  875.  
  876.                         CHAPTER 19: Structures
  877.                         ----------------------
  878.  
  879. 19.5.
  880. -----
  881.  
  882. The :PRINT-FUNCTION option should contain a lambda expression
  883.   (lambda (structure stream depth) (declare (ignore depth)) ...)
  884. This lambda expression names a function whose task is to output the external
  885. representation of structure onto the stream. This may be done by outputting
  886. text onto the stream using WRITE-CHAR, WRITE-STRING, WRITE, PRIN1, PRINC,
  887. PRINT, PPRINT, FORMAT and the like. The following rules must be obeyed:
  888. * The value of *PRINT-ESCAPE* must be respected.
  889. * The value of *PRINT-PRETTY* should not and cannot be respected, since the
  890.   pretty-print mechanism is not accessible from outside.
  891. * The value of *PRINT-CIRCLE* need not to be respected. This is managed by
  892.   the system. (But the print-circle mechanism handles only those objects that
  893.   are (direct or indirect) components of structure.)
  894. * The value of *PRINT-LEVEL* is respected by
  895.   WRITE, PRIN1, PRINC, PRINT, PPRINT, FORMAT ~A, FORMAT ~S, FORMAT ~W and
  896.   FORMAT ~D,~B,~O,~X,~R,~F,~E,~G,~$ with not-numerical arguments.
  897.   Therefore the print-level mechanism works automatically if only these
  898.   functions are used for outputting objects and if they are not called on
  899.   objects with nesting level > 1. (The print-level mechanism does not
  900.   recognize how many parentheses you have output. It only counts how many
  901.   times it was called recursively.)
  902. * The value of *PRINT-LENGTH* must be respected, especially if you are
  903.   outputting an arbitrary number of components.
  904. * The value of *PRINT-READABLY* must be respected. Remember that the values
  905.   of *PRINT-ESCAPE*, *PRINT-LEVEL*, *PRINT-LENGTH* don't matter if
  906.   *PRINT-READABLY* is true.
  907.   The value of *PRINT-READABLY* is respected by PRINT-UNREADABLE-OBJECT,
  908.   WRITE, PRIN1, PRINC, PRINT, PPRINT, FORMAT ~A, FORMAT ~S, FORMAT ~W and
  909.   FORMAT ~D,~B,~O,~X,~R,~F,~E,~G,~$ with not-numerical arguments.
  910.   Therefore *PRINT-READABLY* will be respected automatically if only these
  911.   functions are used for outputting objects.
  912. * You need not bother about the values of *PRINT-BASE*, *PRINT-RADIX*,
  913.   *PRINT-CASE*, *PRINT-GENSYM*, *PRINT-ARRAY*, *PRINT-CLOSURE*, *PRINT-RPARS*.
  914.  
  915. The :INHERIT option is exactly like :INCLUDE except that it doesn't create
  916. new accessors for the inherited slots. Use this option to avoid the problems
  917. that occur when using the same :CONC-NAME for the new and the inherited
  918. structure.
  919.  
  920.  
  921.                        CHAPTER 20: The Evaluator
  922.                        -------------------------
  923.  
  924. As in Scheme, the Macro (THE-ENVIRONMENT) returns the current lexical
  925. environment. This works only in interpreted code and is not compilable!
  926.  
  927. (EVAL-ENV form [env]) evaluates a form in a given lexical environment, just
  928. if the form had been part of the program text that environment came from.
  929.  
  930.  
  931.                          CHAPTER 21: Streams
  932.                          -------------------
  933.  
  934. 21.1.
  935. -----
  936.  
  937. *TERMINAL-IO* is not the only stream that communicates directly with the
  938. user: During execution of the body of a (WITH-KEYBOARD . body) form,
  939. *KEYBOARD-INPUT* is the stream that reads the keystrokes from the keyboard.
  940. It returns every keystroke in detail, as character with the following bits:
  941.   CHAR-CODE    the Ascii code for standard keys,
  942.                for non-standard keys:
  943.   CONTROL      if pressed together with the Control key.
  944. This keyboard input is not echoed on the screen.
  945. During execution of a (WITH-KEYBOARD . body) form, no input from *TERMINAL-IO*
  946. or any synonymous stream should be requested.
  947.  
  948. 21.2.
  949. -----
  950.  
  951. The macro WITH-OUTPUT-TO-PRINTER
  952.        (with-output-to-printer (var) {declaration}* {form}*)
  953. binds the variable var to an output stream that sends its output to the
  954. printer.
  955.  
  956. Generic streams are user programmable streams. The programmer interface:
  957.  
  958.   (MAKE-GENERIC-STREAM controller) returns a generic stream.
  959.  
  960.   (GENERIC-STREAM-CONTROLLER stream)
  961.      returns a private object to which generic stream methods dispatch.
  962.      The typical usage is to retrieve the object originally provided by the
  963.      user in MAKE-GENERIC-STREAM.
  964.  
  965.   (GENERIC-STREAM-P stream)
  966.     determines whether a stream is a generic stream, returning T if it is,
  967.     NIL otherwise.
  968.  
  969. In order to specify the behaviour of a generic stream, the user must define
  970. CLOS methods on the following CLOS generic functions. The function
  971. GENERIC-STREAM-XYZ corresponds to the Common Lisp function XYZ. They all
  972. take a controller and some number of arguments.
  973.  
  974.   (GENERIC-STREAM-READ-CHAR    controller)
  975.   (GENERIC-STREAM-READ-BYTE    controller)
  976.          These generic functions should return NIL at end of file.
  977.          Takes one argument, the controller object.
  978.   (GENERIC-STREAM-LISTEN       controller)
  979.          Returns -1 for EOF, 0 for character pending, and 1 for none.
  980.          Takes one argument, the controller object.
  981.   (GENERIC-STREAM-WRITE-CHAR   controller ch)
  982.          First argument is the controller object.
  983.          Second argument is the character to be written.
  984.   (GENERIC-STREAM-WRITE-BYTE   controller by)
  985.          First argument is the controller object.
  986.          Second argument is the integer to be written.
  987.   (GENERIC-STREAM-WRITE-STRING controller string start len)
  988.          Called with argument list (controller string start len),
  989.          this function shall write
  990.            (subseq (the string string) start (+ start len))
  991.          First argument is the controller object.
  992.   (GENERIC-STREAM-CLEAR-INPUT   controller)
  993.   (GENERIC-STREAM-CLEAR-OUTPUT  controller)
  994.   (GENERIC-STREAM-FINISH-OUTPUT controller)
  995.   (GENERIC-STREAM-FORCE-OUTPUT  controller)
  996.   (GENERIC-STREAM-CLOSE         controller)
  997.          Takes one argument, the controller object.
  998.  
  999. 21.3.
  1000. -----
  1001.  
  1002. CLOSE ignores its :ABORT argument.
  1003.  
  1004.  
  1005.                      CHAPTER 22: Input/Output
  1006.                      ------------------------
  1007.  
  1008. 22.1.2.
  1009. -------
  1010.  
  1011. A "reserved token", i.e. a token that has potential number syntax but cannot
  1012. be interpreted as a number, is interpreted as symbol when being read. (CLtL1
  1013. p. 341)
  1014.  
  1015. When a token with package markers is read, then (CLtL1 p. 343/344) no
  1016. checking is done whether the package part and the symbol-name part do not
  1017. have number syntax. (What's the purpose of this check?) So we consider
  1018. tokens like USER:: or :1 or LISP::4711 or 21:3 as symbols.
  1019.  
  1020. 22.1.3.
  1021. -------
  1022.  
  1023. The backquote read macro also works when nested. Example:
  1024.  (eval ``(,#'(lambda () ',a) ,#'(lambda () ',b)))
  1025.  = (eval `(list #'(lambda () ',a) #'(lambda () ',b)))
  1026.  = (eval (list 'list (list 'function (list 'lambda nil (list 'quote a)))
  1027.                      (list 'function (list 'lambda nil (list 'quote b)))
  1028.    )     )
  1029.  
  1030. Multiple backquote combinations like ,,@ or ,@,@ are not implemented. Their
  1031. use would be confusing anyway.
  1032.  
  1033. 22.1.4.
  1034. -------
  1035.  
  1036. #\ allows inputting characters of arbitrary code: #\Code231 yields the
  1037. character (code-char 231.).
  1038.  
  1039. Additional read dispatch macros:
  1040. * #Y is used to read compiled functions.
  1041. * #" is used to read pathnames:
  1042.      #"test.lsp" is the value of (pathname "test.lsp")
  1043.      As in all strings, backslashes must be written twice here:
  1044.      #"\\.test.lsp"
  1045.  
  1046. 22.1.5.
  1047. -------
  1048.  
  1049. Is it impossible to get the read macro function of a dispatch macro
  1050. character like #\# using GET-MACRO-CHARACTER.
  1051.  
  1052. The CLtL2 place READTABLE-CASE is implemented. The possible values of
  1053. (READTABLE-CASE readtable) are :UPCASE, :DOWNCASE and :PRESERVE.
  1054.  
  1055. 22.1.6.
  1056. -------
  1057.  
  1058. In absence of SYS::WRITE-FLOAT, floating point numbers are output in radix 2.
  1059.  
  1060. If *PRINT-READABLY* is true, *READ-DEFAULT-FLOAT-FORMAT* has no influence on
  1061. the way floating point numbers are printed.
  1062.  
  1063. Pathnames are written according to the syntax #"namestring" if
  1064. *PRINT-ESCAPE* /= NIL. If *PRINT-ESCAPE* = NIL, only the namestring is
  1065. printed.
  1066.  
  1067. *PRINT-CASE* controls the output not only of symbols, but also of characters
  1068. and some #<...> objects.
  1069.  
  1070. *PRINT-PRETTY* is initially = NIL.
  1071.  
  1072. *PRINT-ARRAY* is initially = T.
  1073.  
  1074. An additional variable *PRINT-CLOSURE* controls whether compiled and
  1075. interpreted functions (closures) are output in detailed form. If
  1076. *PRINT-CLOSURE* /= NIL, compiled closures are output in #Y syntax the reader
  1077. understands. *PRINT-CLOSURE* is initially = NIL.
  1078.  
  1079. An additional variable *PRINT-RPARS* controls the output of right (closing)
  1080. parentheses. If *PRINT-RPARS* /= NIL, closing parentheses which don't fit
  1081. onto the same line as the the corresponding opening parenthesis are output
  1082. just below their corresponding opening parenthesis, in the same column.
  1083. *PRINT-RPARS* is initially = T.
  1084.  
  1085. 22.2.1.
  1086. -------
  1087.  
  1088. The function READ-CHAR-SEQUENCE performs multiple READ-CHAR operations:
  1089. (READ-CHAR-SEQUENCE sequence stream [:start] [:end]) fills the
  1090. subsequence of sequence specified by :start and :end with characters
  1091. consecutively read from stream. It returns the index of the first element
  1092. of sequence that was not updated (= end or < end if the stream reached its
  1093. end).
  1094. This function is especially efficient if sequence is a string and stream is
  1095. a file stream with element type STRING-CHAR, a pipe stream or a string input
  1096. stream.
  1097.  
  1098. 22.2.2.
  1099. -------
  1100.  
  1101. The function READ-BYTE-SEQUENCE performs multiple READ-BYTE operations:
  1102. (READ-BYTE-SEQUENCE sequence stream [:start] [:end]) fills the
  1103. subsequence of sequence specified by :start and :end with integers
  1104. consecutively read from stream. It returns the index of the first element
  1105. of sequence that was not updated (= end or < end if the stream reached its
  1106. end).
  1107. This function is especially efficient if sequence is a
  1108. (VECTOR (UNSIGNED-BYTE 8)) and stream is a file stream with element type
  1109. (UNSIGNED-BYTE 8) or a pipe stream.
  1110.  
  1111. 22.3.1.
  1112. -------
  1113.  
  1114. The functions WRITE and WRITE-TO-STRING have an additional keyword :CLOSURE
  1115. that can be used to bind *PRINT-CLOSURE*.
  1116.  
  1117. The CLtL2 macro PRINT-UNREADABLE-OBJECT is implemented.
  1118.  
  1119. The function WRITE-CHAR-SEQUENCE performs multiple WRITE-CHAR operations:
  1120. (WRITE-CHAR-SEQUENCE sequence stream [:start] [:end]) outputs the characters
  1121. of the subsequence of sequence specified by :start and :end to stream.
  1122. It returns sequence.
  1123. This function is especially efficient if sequence is a string and stream is
  1124. a file stream with element type STRING-CHAR or a pipe stream.
  1125.  
  1126. 22.3.2.
  1127. -------
  1128.  
  1129. The function WRITE-BYTE-SEQUENCE performs multiple WRITE-BYTE operations:
  1130. (WRITE-BYTE-SEQUENCE sequence stream [:start] [:end]) outputs the integers
  1131. of the subsequence of sequence specified by :start and :end to stream.
  1132. It returns sequence.
  1133. This function is especially efficient if sequence is a
  1134. (VECTOR (UNSIGNED-BYTE 8)) and stream is a file stream with element type
  1135. (UNSIGNED-BYTE 8) or a pipe stream.
  1136.  
  1137. 22.3.3.
  1138. -------
  1139.  
  1140. The FORMAT option ~W is analogous to ~A and ~S, but avoids binding of
  1141. *PRINT-ESCAPE*. (FORMAT stream "~W" object) is equivalent to
  1142. (WRITE object :stream stream).
  1143.  
  1144. FORMAT ~R and FORMAT ~:R can output only integers in the range |n| < 10^66.
  1145. The output is in English, according to the American conventions, and these
  1146. conventions are identical to the British conventions only in the range
  1147. |n| < 10^9.
  1148.  
  1149. FORMAT ~:@C does not output the character itself, only the instruction how
  1150. to type the character.
  1151.  
  1152. For FORMAT ~E and FORMAT ~G, the value of *READ-DEFAULT-FLOAT-FORMAT* doesn't
  1153. matter if *PRINT-READABLY* is true.
  1154.  
  1155. FORMAT ~T can determine the current column of any stream.
  1156.  
  1157.  
  1158.                     CHAPTER 23: File System Interface
  1159.                     ---------------------------------
  1160.  
  1161. 23.1.
  1162. -----
  1163.  
  1164. For most operations, pathnames denoting files and pathnames denoting
  1165. directories can not be used interchangeably.
  1166. For example, #"FOO.BAR" denotes the file FOO in the directory BAR, while
  1167. #"FOO.BAR." denotes the subdirectory BAR of the directory FOO.
  1168. This is especially important for the functions DIRECTORY, DIR, CD, MAKE-DIR,
  1169. DELETE-DIR.
  1170.  
  1171. The minimum filename syntax that may be used portably is:
  1172.   "xxx"       for a file with name xxx,
  1173.   "xxx.yy"    for a file with name xxx and type yy,
  1174.   ".yy"       for a pathname with type yy and no name specified.
  1175. Hereby xxx denote 1 to 8 characters, and yy denote 1 to 3 characters, each of
  1176. which being either alphanumerical or the underscore #\_.
  1177. Other properties of pathname syntax vary between operating systems.
  1178.  
  1179. 23.1.1.
  1180. -------
  1181.  
  1182. RISC OS provides several filing systems as standard (ADFS, IDEFS, NetFS,
  1183. RamFS, NetPrint) and support for extra filing systems (DOSFS, ResourceFS and
  1184. DeviceFS).
  1185.  
  1186. A module called FileSwitch is at the centre of all filing system operation
  1187. in RISC OS. FileSwitch provides a common core of functions used by all
  1188. filing systems. It only provides the parts of these services that are device
  1189. independent. The device dependant services that control the hardware are
  1190. provided by separate modules, which are the actual filing systems.
  1191. FileSwitch keeps track of active filing systems and switches betwen them as
  1192. necessary.
  1193.  
  1194. One of the filing system modules that RISC OS provides is FileCore. It takes
  1195. the normal calls that FileSwitch sends to a filing system module, and
  1196. converts them to a simpler set of calls to modules that control the
  1197. hardware. Unlike FileSwitch it creates a fresh instantiation of itself for
  1198. each module that it supports. Using FileCore to build filing system modules
  1199. imposes a more rigid structure on it, as more of the filing system is
  1200. predefined.
  1201.  
  1202. As well as standard filing systems, FileSwitch supports image filing
  1203. systems. These provide facilities for RISC OS to handle media in foreign
  1204. formats, and to support `image files' (or partitions) in those formats.
  1205. Rather than accessing the hardware directly they rely on standard RISC OS
  1206. filing systems to do so. DOSFS is an example of an image filing system used
  1207. to handle DOS format discs.
  1208.  
  1209. Terminology
  1210.  
  1211. A pathname may include a filing system name, a special field, a media name
  1212. (e.g., a disc name), directory name(s), and the name of the object itself;
  1213. each of these parts of a pathname is known as an `element' of the pathname.
  1214.  
  1215. Filenames
  1216.  
  1217. Filename `elements' may be up to ten characters in length on FileCore-based
  1218. filing systems and on NetFS. These characters may be digits or letters.
  1219. FileSwitch makes no distinction between upper and lower case, although
  1220. filing systems can do so. As a general rule, you should not use top-bit-set
  1221. characters in filenames, although some filing systems (such as
  1222. FileCore-based ones) support them. Other characters may be used provided
  1223. they do not have a special significance. Those that do are listed below :
  1224.  
  1225.    .   Separates directory specifications, e.g., $.fred
  1226.    :   Introduces a drive or disc specification, e.g., :0, :bigdisc. It also
  1227.        marks the end of a filing system name, e.g., adfs:
  1228.    *   Acts as a `wildcard' to match zero or more characters.
  1229.    #   Acts as a `wildcard' to match any single character.
  1230.    $   is the name of the root directory of the disc.
  1231.    &   is the user root directory (URD)
  1232.    @   is the currently selected directory (CSD)
  1233.    ^   is the `parent' directory
  1234.    %   is the currently selected library (CSL)
  1235.    \   is the previously selected directory (PSD)
  1236.  
  1237. Directories
  1238.  
  1239. The root directory, $, forms the top of the directory hierarchy
  1240. of the media which contains the CSD. $ does not have a parent directory,
  1241. trying to access its parent will just access $. Each directory name is
  1242. separated by a '.' character. For example:
  1243.  
  1244.    $.Documents.Memos
  1245.    %.cc
  1246.  
  1247. Filing Systems
  1248.  
  1249. Files may also be accessed on filing systems other than the current one by
  1250. prefixing the filename with a filing system specification. A filing system
  1251. name may appear between '-' characters, or suffixed by a ':', though the
  1252. latter is advised since '-' can also be used to introduce a parameter on a
  1253. command line, or as part of a file name. For example:
  1254.  
  1255.    -net-$.SystemMesg
  1256.    adfs:%.aasm
  1257.  
  1258. Special Fields
  1259.  
  1260. Special fields are used to supply more information to the filing system than
  1261. you can using standard path names; for example NetFS and NetPrint use them
  1262. to specify server addresses or names. They are introduced by a '#'
  1263. character; a variety of syntaxes are possible:
  1264.  
  1265.    net#MJHardy::disc1.mike
  1266.       #MJHardy::disc1.mike
  1267.   -net#MJHardy-:disc1.mike
  1268.      -#MJHardy-:disc1.mike
  1269.  
  1270. The special fields here are all MJHardy, and give the name of the fileserver
  1271. to use. Special fields may use any character except for control characters,
  1272. double quote '"', solidus '|' and space. If a special field contains a hypen
  1273. you may only use the first two syntaxes given above.
  1274.  
  1275. File$Path and Run$Path
  1276.  
  1277. These two special variables control exactly where a file will be looked for,
  1278. according to the operation being performed on it.
  1279.  
  1280.    File$Path   for read operations
  1281.    Run$Path    for execute operations
  1282.  
  1283. The contents of each variable should expand to a list or prefixes, separated
  1284. by commas. When a read operation is performed then the prefixes in File$Path
  1285. are used in the order in which they are listed. The first object that
  1286. matches is used, whether it be a file or directory. Similarly any execute
  1287. operation uses the prefixes in Run$Path. These search paths are only used
  1288. when the pathname does not contain an explicit filing system reference,
  1289. e.g., executing adfs:file will not use Run$Path.
  1290.  
  1291. Other path variables
  1292.  
  1293. You can set up other path variables and use them as pseudo filing systems.
  1294. For example if you typed:
  1295.  
  1296.    *Set Source$Path adfs:$.src.,adfs:$.public.src.
  1297.  
  1298. you could then refer to the pseudo filing system as Source: or (less
  1299. preferable) as -Source-. These path variables work in the same was as
  1300. File$Path and Run$Path.
  1301.  
  1302. NOTE. Path variables are not implemented in this version of CLISP. A
  1303. workaround for this is to use "<Foo$Path>" instead of "Foo:" until they are
  1304. made available.
  1305.  
  1306. from Lisp-string notation to internal representation
  1307. ----------------------------------------------------
  1308. NO swapping. "foo.lsp" means file type "lsp" and file name "foo".
  1309. This is pseudo-BNF:
  1310.  
  1311. legal character ::= any ISO latin-1 graphic character >= ' ' except
  1312.                     '.' ':' '*' '#' '$' '&' '@' '^' '%' '\' '?'
  1313.  
  1314. extended legal character ::= any ISO latin-1 graphic character >= ' ' except
  1315.                              ':' '"' '|'
  1316.  
  1317. legal-wild char ::= legal char | '*' | '#' | '?'
  1318.  
  1319. host ::=   '-' { extended legal char except '-' }+ '-'
  1320.          | { extended legal char except '-' } { extended legal char }* ':'
  1321.          | empty
  1322.  
  1323. device ::=   ':' { legal char }+ '.'
  1324.            | empty
  1325.  
  1326. directory ::=   { '$' | '&' | '@' | '%' | '\' } '.' { subdirectory }*
  1327.               | { subdirectory }+
  1328.               | empty
  1329.  
  1330. '$' -> :ABSOLUTE :ROOT, '&' -> :ABSOLUTE :HOME, '@' -> :ABSOLUTE :CURRENT,
  1331. '%' -> :ABSOLUTE :LIBRARY, '\' -> :ABSOLUTE :PREVIOUS, else :RELATIVE.
  1332.  
  1333. subdirectory ::= { '^' | { legal-wild char }+ } '.'
  1334.                  '^' -> :PARENT
  1335.  
  1336. filename ::= { { legal-wild char }+ | empty }
  1337.  
  1338. filetype ::= { '.' { legal-wild char }+ | empty }
  1339.  
  1340. pathname ::= host device directory filename filetype
  1341.  
  1342. Examples:
  1343. String                          Hostname Device  Directory            Name         Type
  1344. -net-$.SystemMesg                "net"   NIL     (:ABSOLUTE :ROOT)    "SystemMesg" NIL
  1345. net#MJHardy::disc1.mike    "net#MJHardy" "disc1" (:ABSOLUTE :ROOT)    "mike"       NIL
  1346. #MJHardy::disc1.mike          "#MJHardy" "disc1" (:ABSOLUTE :ROOT)    "mike"       NIL
  1347. -net#MJHardy-:disc1.mike   "net#MJHardy" "disc1" (:ABSOLUTE :ROOT)    "mike"       NIL
  1348. -#MJHardy-:disc1.mike         "#MJHardy" "disc1" (:ABSOLUTE :ROOT)    "mike"       NIL
  1349. @.foo                            NIL     NIL     (:ABSOLUTE :CURRENT) "foo"        NIL
  1350. foo                              NIL     NIL     (:RELATIVE)          "foo"        NIL
  1351. ^.                               NIL     NIL     (:RELATIVE :PARENT)  NIL          NIL
  1352. @.^.                             NIL     NIL     (:ABSOLUTE :CURRENT :PARENT) NIL  NIL
  1353. foo.bar                          NIL     NIL     (:RELATIVE)          "foo"        "bar"
  1354. foo.bar.baz                      NIL     NIL     (:RELATIVE "foo")    "bar"        "baz"
  1355. foo.bar.                         NIL     NIL     (:RELATIVE "foo" "bar") NIL       NIL
  1356. foo.@.                       illegal
  1357.  
  1358. from internal representation to RISCOS string
  1359. ---------------------------------------------
  1360. with swapping _only_ of name/type components.
  1361.  
  1362. Hostname    Device  Directory                   Name    Type      RISCOS String
  1363.  
  1364. "net"       "disc1" (:ABSOLUTE :ROOT)           "foo"   NIL       "net::disc1.$.foo"
  1365. "net#MJ"    "disc1" (:ABSOLUTE :ROOT "foo")     "bar"   "baz"     "net#MJ::disc1.$.foo.baz.bar"
  1366. "adfs"      "4"     (:ABSOLUTE :ROOT "foo" "bar") NIL   NIL       "adfs::4.$.foo.bar"
  1367. NIL         "disc1" (:ABSOLUTE :ROOT "foo")     "bar"   NIL       ":disc1.$.foo.bar"
  1368. NIL         "disc1" (:ABSOLUTE :CURRENT)        NIL     NIL       illegal here
  1369. NIL         "disc1" (:RELATIVE)                 NIL     NIL       ":disc1."
  1370. NIL         "disc1" NIL                         NIL     NIL       ":disc1."
  1371. NIL         NIL     (:ABSOLUTE :ROOT)           "foo"   NIL       "$.foo"
  1372. NIL         NIL     (:ABSOLUTE :CURRENT)        "foo"   NIL       "@.foo"
  1373. NIL         NIL     (:RELATIVE)                 "foo"   "bar"     "bar.foo"
  1374. NIL         NIL     (:RELATIVE "foo")           "bar"   "baz"     "foo.baz.bar"
  1375. NIL         NIL     (:ABSOLUTE :LIBRARY)        "bar"   NIL       "%.bar"
  1376. NIL         NIL     (:ABSOLUTE :LIBRARY "foo")  "bar"   NIL       "%.foo.bar"
  1377. NIL         NIL     (:RELATIVE)                 "foo"   "bar"     "bar.foo"
  1378. NIL         NIL     (:RELATIVE "foo")           "bar"   NIL       "foo.bar"
  1379. NIL         NIL     (:RELATIVE "foo")           NIL     "bar"     illegal here
  1380.  
  1381. That is, the RISCOS string is the flattenation-concatenation of
  1382.   (append
  1383.     (if (null hostname) "" (append hostname ":"))
  1384.     (if (null device) "" (append ":" device "."))
  1385.     (case (pop directory)
  1386.       (:ABSOLUTE (case (pop directory) (:ROOT "$.") (:HOME "&.") (:CURRENT "@.")
  1387.                                        (:LIBRARY "%.") (:PREVIOUS "\\.")))
  1388.       (:RELATIVE "")
  1389.     )
  1390.     (mapcar (lambda (subdir) (append subdir ".")) directory)
  1391.     (if (null name)
  1392.       (if (null type) "" (error "type with name illegal here"))
  1393.       (if (null type)
  1394.         name
  1395.         (append type "." name)
  1396.   ) ) )
  1397.  
  1398. internal representation
  1399. -----------------------
  1400.  
  1401. Pathname components:
  1402. HOST          Simple-String or NIL
  1403. DEVICE        Simple-String or NIL
  1404. DIRECTORY     (Startpoint . Subdirs) where
  1405.                Startpoint = :RELATIVE | :ABSOLUTE Anker
  1406.                Anker = :ROOT | :HOME | :CURRENT | :LIBRARY | :PREVIOUS
  1407.                Subdirs = () | (subdir . Subdirs)
  1408.                subdir = :PARENT or
  1409.                subdir = simple string, may contain wildcard characters ?,# and *
  1410. NAME          NIL or
  1411.               simple string, may contain wildcard characters ?,# and *
  1412.               (may also be specified as :WILD)
  1413. TYPE          NIL or
  1414.               simple string, may contain wildcard characters ?,# and *
  1415.               (may also be specified as :WILD)
  1416. VERSION       always NIL (may also be specified as :WILD or :NEWEST)
  1417.  
  1418. Constraint: startpoint /= :ABSOLUTE :ROOT only if device = NIL. If the device
  1419. is specified, the pathname must be :ABSOLUTE :ROOT.
  1420.  
  1421.  
  1422. The wildcard characters: '*' matches any sequence of characters, '#' or '?'
  1423. matches any one character.
  1424.  
  1425. Due to the name/type swapping rule, there are pathnames that can't result
  1426. from PARSE-NAMESTRING. To get a pathname whose type is NIL, MAKE-PATHNAME
  1427. must be used.
  1428. Example: (MAKE-PATHNAME :DIRECTORY "!Clisp." :NAME "README").
  1429.  
  1430. 23.1.2.
  1431. -------
  1432.  
  1433. External notation of pathnames (cf. PARSE-NAMESTRING and NAMESTRING),
  1434. of course without spaces, [,],{,}:
  1435. see above.
  1436.  
  1437. NAMESTRING has an optional flag argument: (NAMESTRING pathname T) returns an
  1438. external notation suitable for passing to the operating system or other
  1439. programs.
  1440.  
  1441. 23.1.4.
  1442. -------
  1443.  
  1444. The CLtL2 functions WILD-PATHNAME-P, PATHNAME-MATCH-P and TRANSLATE-PATHNAME
  1445. are implemented.
  1446.  
  1447. PATHNAME-MATCH-P does not interpret missing components as wild.
  1448.  
  1449. TRANSLATE-PATHNAME has two additional keywords:
  1450.   (TRANSLATE-PATHNAME source from-wildname to-wildname &key :all :merge)
  1451. If :ALL is specified and non-NIL, a list of all resulting pathnames,
  1452. corresponding to all matches of (PATHNAME-MATCH-P source from-wildname),
  1453. is returned. If :MERGE is specified and NIL, unspecified pieces of to-pathname
  1454. are not replaced by corresponding pieces of source.
  1455.  
  1456. 23.1.5.
  1457. -------
  1458.  
  1459. The functions LOGICAL-PATHNAME, TRANSLATE-LOGICAL-PATHNAME,
  1460. LOGICAL-PATHNAME-TRANSLATIONS, (SETF LOGICAL-PATHNAME-TRANSLATIONS),
  1461. LOAD-LOGICAL-PATHNAME-TRANSLATIONS, COMPILE-FILE-PATHNAME are implemented.
  1462.  
  1463. RENAME-FILE always returns a non-logical pathname as its first value.
  1464.  
  1465. 23.1.6.
  1466. -------
  1467.  
  1468. (PARSE-NAMESTRING string [host [defaults]]) returns a logical pathname only
  1469. if host is a logical host or host is NIL and defaults is a logical pathname.
  1470. To construct a logical pathname from a string, the function LOGICAL-PATHNAME
  1471. can be used.
  1472.  
  1473. (MERGE-PATHNAMES string [defaults]) returns a logical pathname only if
  1474. defaults is a logical pathname. To construct a logical pathname from a string,
  1475. the function LOGICAL-PATHNAME can be used.
  1476.  
  1477. 23.2.
  1478. -----
  1479.  
  1480. The file streams returned by OPEN are always buffered.
  1481.  
  1482. 23.3.
  1483. -----
  1484.  
  1485. FILE-AUTHOR always returns NIL.
  1486.  
  1487. 23.4.
  1488. -----
  1489.  
  1490. LOAD has two additional keywords :ECHO and :COMPILING.
  1491. (LOAD filename &key :verbose :print :echo :if-does-not-exist :compiling)
  1492. :VERBOSE T   causes LOAD to emit a short message that a file is being loaded.
  1493.              The default is *LOAD-VERBOSE*, which is initially = T.
  1494. :PRINT T     causes LOAD to print the value of each form.
  1495.              The default is *LOAD-PRINT*, which is initially = NIL.
  1496. :ECHO T      causes the input from the file to be echoed to *STANDARD-OUTPUT*
  1497.              (normally to the screen). Should there be an error in the file,
  1498.              you can see at one glance where it is.
  1499.              The default is *LOAD-ECHO*, which is initially = NIL.
  1500. :COMPILING T causes each form read to be compiled on the fly. The compiled
  1501.              code is executed at once and - in contrast to COMPILE-FILE -
  1502.              not written to a file.
  1503.  
  1504. The CLtL2 variables *LOAD-PATHNAME* and *LOAD-TRUENAME* are implemented.
  1505.  
  1506. The variable *LOAD-PATHS* contains a list of directories where program files
  1507. are searched - additionally to the specified or current directory - by LOAD,
  1508. REQUIRE, COMPILE-FILE.
  1509.  
  1510. 23.5.
  1511. -----
  1512.  
  1513. (DIRECTORY [pathname [:full] [:circle]]) can run in two modes:
  1514. * If pathname contains no name or type component, a list of all matching
  1515.   directories is produced.
  1516. * Otherwise a list of all matching files is returned. If the :FULL argument
  1517.   is /= NIL, this contains additional information: for each matching file
  1518.   you get a list of at least four elements
  1519.   (file-pathname file-truename file-write-date-as-decoded-time file-length).
  1520.  
  1521. (DIR [pathname]) is like DIRECTORY, but displays the pathnames instead of
  1522. returning them. (DIR) shows the contents of the current directory.
  1523.  
  1524. (CD [pathname]) manages the current host, current device and the current directory.
  1525. (CD pathname) sets it, (CD) returns it.
  1526.  
  1527. (DEFAULT-DIRECTORY) is equivalent to (CD), (SETF (DEFAULT-DIRECTORY) pathname)
  1528. is equivalent to (CD pathname).
  1529.  
  1530. (MAKE-DIR directory-pathname) creates a new subdirectory.
  1531.  
  1532. (DELETE-DIR directory-pathname) removes an (empty) subdirectory.
  1533.  
  1534. (EXECUTE programfile arg1 arg2 ...)  executes an external program. Its name
  1535. is programfile. It is given the strings arg1, arg2, ... as arguments.
  1536.  
  1537. (SHELL [command])  calls the operating system's shell.
  1538. (SHELL) calls the shell for interactive use. (SHELL command) calls the shell
  1539. only for execution of the one given command.
  1540.  
  1541.  
  1542.                         CHAPTER 24: Errors
  1543.                         ------------------
  1544.  
  1545. 24.1.
  1546. -----
  1547.  
  1548. When an error occurred, you are in a break loop. You can evaluate forms as
  1549. usual. The HELP command (or help key if there is one) lists the available
  1550. debugging commands.
  1551.  
  1552.  
  1553.                   CHAPTER 25: Miscellaneous Features
  1554.                   ----------------------------------
  1555.  
  1556. 25.1.
  1557. -----
  1558.  
  1559. The compiler can be called not only by the functions COMPILE, COMPILE-FILE
  1560. and DISASSEMBLE, also by the declaration (COMPILE).
  1561.  
  1562. (COMPILE-FILE input-file [:output-file] [:listing]
  1563.                          [:warnings] [:verbose] [:print])
  1564. compiles a file to bytecode.
  1565.     input-file                should be a pathname/string/symbol.
  1566. The :output-file argument     should be NIL or T or a pathname/string/symbol
  1567.                               or an output-stream. The default is T.
  1568. The :listing argument         should be NIL or T or a pathname/string/symbol
  1569.                               or an output-stream. The default is NIL.
  1570. The :warnings argument        specifies whether warnings should also appear
  1571.                               on the screen.
  1572. The :verbose argument         specifies whether error messages should also
  1573.                               appear on the screen.
  1574. The :print argument           specifies whether an indication which forms are
  1575.                               being compiled should appear on the screen.
  1576. The variables *COMPILE-WARNINGS*, *COMPILE-VERBOSE*, *COMPILE-PRINT* provide
  1577. defaults for the :warnings, :verbose, :print keyword arguments, respectively.
  1578.  
  1579. The CLtL2 variables *COMPILE-FILE-PATHNAME* and *COMPILE-FILE-TRUENAME* are
  1580. implemented.
  1581.  
  1582. The CLtL2 special form LOAD-TIME-VALUE is implemented. (LOAD-TIME-VALUE form)
  1583. is like (QUOTE #,form) except that the former can be generated by macros.
  1584.  
  1585. The CLtL2 function FUNCTION-LAMBDA-EXPRESSION is implemented.
  1586. (FUNCTION-LAMBDA-EXPRESSION function) returns information about the source
  1587. of an interpreted function: lambda-expression, lexical environment, name.
  1588.  
  1589. 25.2.
  1590. -----
  1591.  
  1592. No on-line documentation is available for the system functions (yet).
  1593.  
  1594. 25.3.
  1595. -----
  1596.  
  1597. (TRACE fun ...) makes the functions fun, ... traced. Syntax of fun:
  1598. Either a symbol:
  1599.        symbol
  1600. or a list of a symbol and some keywords and arguments (which must come in
  1601. pairs!):
  1602.        (symbol
  1603.          [:suppress-if form]   ; no trace output as long as form is true
  1604.          [:step-if form]       ; invokes the stepper as soon as form is true
  1605.          [:pre form]           ; evaluates form before calling the function
  1606.          [:post form]          ; evaluates form after return from the function
  1607.          [:pre-break-if form]  ; goes into the break loop before calling the
  1608.                                ; function if form is true
  1609.          [:post-break-if form] ; goes into the break loop after return from
  1610.                                ; the function if form is true
  1611.          [:pre-print form]     ; prints the values of form before calling the
  1612.                                ; function
  1613.          [:post-print form]    ; prints the values of form after return from
  1614.                                ; the function
  1615.          [:print form]         ; prints the values of form both before
  1616.                                ; calling and after return from the function
  1617.        )
  1618. In all these forms you can access
  1619.   the function itself               as *TRACE-FUNCTION*,
  1620.   the arguments to the function     as *TRACE-ARGS*,
  1621.   the function/macro call as form   as *TRACE-FORM*,
  1622. and after return from the function
  1623.   the list of return values from the function call  as *TRACE-VALUES*,
  1624. and you can leave the function call with specified values by using RETURN.
  1625.  
  1626. TRACE and UNTRACE are also applicable to functions (SETF symbol) and to macros,
  1627. but not to locally defined functions and macros.
  1628.  
  1629. The function INSPECT is not implemented.
  1630.  
  1631. The function ROOM can only be called without arguments. It returns two values:
  1632. the number of bytes currently occupied by Lisp objects, and the number of
  1633. bytes that can be allocated before the next regular garbage collection occurs.
  1634.  
  1635. The function ED calls the external editor specified by the variable *EDITOR*
  1636. (see config.lsp).
  1637.  
  1638. The function UNCOMPILE does the converse of COMPILE: (UNCOMPILE function-name)
  1639. reverts an interpreted function that has been entered or loaded in the same
  1640. session and then compiled back to its interpreted form.
  1641.  
  1642. 25.4.1.
  1643. -------
  1644.  
  1645. The variable *DEFAULT-TIME-ZONE* contains the default time zone used by
  1646. ENCODE-UNIVERSAL-TIME and DECODE-UNIVERSAL-TIME. It is initially set to -1
  1647. (which means 1 hour east of Greenwich, i.e. Mid European Time).
  1648.  
  1649. The timezone in a decoded time must not necessarily be an integer, but (as
  1650. float or rational number) it should be a multiple of 1/4.
  1651.  
  1652. INTERNAL-TIME-UNITS-PER-SECOND = 100.
  1653.  
  1654. 25.4.2.
  1655. -------
  1656.  
  1657. The functions MACHINE-TYPE, MACHINE-VERSION, MACHINE-INSTANCE and
  1658. SHORT-SITE-NAME, LONG-SITE-NAME should be defined by every user in his
  1659. site-specific CONFIG.LSP file.
  1660.  
  1661. The variable *FEATURES* initially contains the symbols
  1662.    CLISP            ; this implementation
  1663.    COMMON-LISP
  1664.    CLTL1
  1665.    INTERPRETER
  1666.    COMPILER
  1667.    LOGICAL-PATHNAMES
  1668.    LOOP
  1669.    CLOS
  1670.    ATARI            ; if hardware = Atari ST/TT and operating system = TOS
  1671.    AMIGA            ; if hardware = Amiga and operating system = Exec/AmigaDOS
  1672.    DOS              ; if hardware = PC (clone) and operating system = DOS
  1673.    OS/2             ; if hardware = PC (clone) and operating system = OS/2
  1674.    PC386            ; if hardware = PC (clone) with a 386/486
  1675.    UNIX             ; if                            operating system = Unix
  1676.                     ;                               (yes, in this case the
  1677.                     ;                               hardware is irrelevant!)
  1678.  
  1679.  
  1680.                            CHAPTER 26: Loop
  1681.                            ----------------
  1682.  
  1683. The CLtL2 macros LOOP and LOOP-FINISH are implemented.
  1684.  
  1685.  
  1686.                  CHAPTER 28: Common Lisp Object System
  1687.                  -------------------------------------
  1688.  
  1689. To use CLOS, do (USE-PACKAGE "CLOS").
  1690.  
  1691. The functions
  1692.   SLOT-VALUE, SLOT-BOUNDP, SLOT-MAKUNBOUND, SLOT-EXISTS-P,
  1693.   FIND-CLASS, (SETF FIND-CLASS), CLASS-OF, CALL-NEXT-METHOD, NEXT-METHOD-P,
  1694.   CLASS-NAME, (SETF CLASS-NAME), NO-APPLICABLE-METHOD, NO-NEXT-METHOD,
  1695.   FIND-METHOD, ADD-METHOD, REMOVE-METHOD, COMPUTE-APPLICABLE-METHODS,
  1696.   METHOD-QUALIFIERS, FUNCTION-KEYWORDS, SLOT-MISSING, SLOT-UNBOUND,
  1697.   PRINT-OBJECT, DESCRIBE-OBJECT, MAKE-INSTANCE, INITIALIZE-INSTANCE,
  1698.   REINITIALIZE-INSTANCE, SHARED-INITIALIZE,
  1699. the macros
  1700.   WITH-SLOTS, WITH-ACCESSORS, DEFCLASS, DEFMETHOD, DEFGENERIC,
  1701.   GENERIC-FUNCTION, GENERIC-FLET, GENERIC-LABELS,
  1702. the classes
  1703.   STANDARD-CLASS, STRUCTURE-CLASS, BUILT-IN-CLASS, STANDARD-OBJECT,
  1704.   STANDARD-GENERIC-FUNCTION, STANDARD-METHOD and all predefined classes,
  1705. and the method combination
  1706.   STANDARD
  1707. are implemented.
  1708.  
  1709. Deviations from CLtL2 chapter 28:
  1710.  
  1711. DEFCLASS : It *is* required that the superclasses of a class be defined before
  1712. the DEFCLASS form for the class is evaluated.
  1713.  
  1714. The REAL type is added to the predefined classes listed in table 28-1.
  1715.  
  1716. Only STANDARD method combination is implemented.
  1717.  
  1718. When CALL-NEXT-METHOD is called with arguments, the rule that the ordered
  1719. set of applicable methods must be the same as for the original arguments
  1720. is not enforced by the implementation.
  1721.  
  1722. CALL-NEXT-METHOD and NEXT-METHOD-P are local macros, not local functions.
  1723. Use #'(lambda () (call-next-method)) instead of #'call-next-method if you
  1724. really need it as a function.
  1725.  
  1726. There is a generic function NO-PRIMARY-METHOD (analogous to
  1727. NO-APPLICABLE-METHOD) which is called when a generic function of the class
  1728. STANDARD-GENERIC-FUNCTION is invoked and no primary method on that generic
  1729. function is applicable.
  1730.  
  1731. GENERIC-FLET and GENERIC-LABELS are implemented as macros, not as special
  1732. forms.
  1733.  
  1734. The function ENSURE-GENERIC-FUNCTION is not implemented.
  1735.  
  1736. ADD-METHOD can put methods into other generic functions than the one the method
  1737. came from.
  1738.  
  1739. PRINT-OBJECT and DESCRIBE-OBJECT are only called on objects of type
  1740. STANDARD-OBJECT.
  1741.  
  1742. DESCRIBE-OBJECT should not call DESCRIBE recursively as this would produce
  1743. more information than is likely to be useful to a human reader.
  1744.  
  1745. DOCUMENTATION still has the CLtL1 implementation.
  1746.  
  1747. User-defined method combination is not supported.
  1748. The sections 28.1.7.3., 28.1.7.4., the macros DEFINE-METHOD-COMBINATION,
  1749. CALL-METHOD and the functions INVALID-METHOD-ERROR, METHOD-COMBINATION-ERROR,
  1750. METHOD-QUALIFIERS are not implemented.
  1751.  
  1752. The special form WITH-ADDED-METHODS is not implemented.
  1753.  
  1754. Redefining classes is not supported.
  1755. The sections 28.1.10., 28.1.10.1., 28.1.10.2., 28.1.10.3., 28.1.10.4. and the
  1756. function UPDATE-INSTANCE-FOR-REDEFINED-CLASS are not implemented.
  1757.  
  1758. Changing the class of a given instance is not supported.
  1759. The sections 28.1.11., 28.1.11.1., 28.1.11.2., 28.1.11.3. and the functions
  1760. CHANGE-CLASS, UPDATE-INSTANCE-FOR-DIFFERENT-CLASS, MAKE-INSTANCES-OBSOLETE are
  1761. not implemented.
  1762.  
  1763.  
  1764.                         CHAPTER 29: Conditions
  1765.                         ----------------------
  1766.  
  1767. 29.4.1.
  1768. -------
  1769.  
  1770. The default condition type for conditions created by SIGNAL is
  1771. SIMPLE-CONDITION, not SIMPLE-ERROR.
  1772.  
  1773. 29.4.7.
  1774. -------
  1775.  
  1776. In RESTART-CASE clauses the argument list can also be specified after the
  1777. keyword/value pairs instead of before them. The syntax therefore is
  1778.   (RESTART-CASE form {restart-clause}*)
  1779. with
  1780.   restart-clause ::=   (restart-name arglist {keyword value}* {form}*)
  1781.                      | (restart-name {keyword value}* arglist {form}*)
  1782.  
  1783. The macro WITH-RESTARTS is like RESTART-CASE, except that the forms are
  1784. specified after the restart clauses instead of before them, and the
  1785. restarts created are not implicitly associated to any condition.
  1786.   (WITH-RESTARTS ({restart-clause}*) {form}*)
  1787. is therefore equivalent to (RESTART-CASE (PROGN {form}*) {restart-clause}*).
  1788.  
  1789. 29.4.8.
  1790. -------
  1791.  
  1792. COMPUTE-RESTARTS and FIND-RESTART behave as specified in dpANS: If the
  1793. optional condition argument is not NIL, only restarts associated with that
  1794. condition and restarts associated to no condition at all are considered.
  1795. Therefore the effect of associating a restart to a condition is not to
  1796. activate it, but to hide it from other conditions. This makes the syntax
  1797. dependent implicit association performed by RESTART-CASE nearly obsolete.
  1798.  
  1799. 29.4.9.
  1800. -------
  1801.  
  1802. The default condition type for conditions created by WARN is SIMPLE-WARNING,
  1803. not SIMPLE-ERROR.
  1804.  
  1805.  
  1806.                CHAPTER 90: Platform independent Extensions
  1807.                -------------------------------------------
  1808.  
  1809. 90.1. Saving an Image
  1810. ---------------------
  1811.  
  1812. The function (SAVEINITMEM [filename [:quiet] [:init-function]]) saves the
  1813. running CLISP's memory to a file. The filename defaults to "lispinit.mem".
  1814. If the :QUIET argument is not NIL, the startup banner and the good-bye
  1815. message will be suppressed. The :INIT-FUNCTION argument specifies a function
  1816. that will be executed at startup of the saved image.
  1817.  
  1818. 90.2. Quitting Lisp
  1819. -------------------
  1820.  
  1821. The functions (EXIT [errorp]), (QUIT [errorp]) and (BYE [errorp])
  1822. - all synonymous - terminate CLISP. If errorp is not NIL, CLISP aborts with
  1823. error status, i.e. the environment is informed that the CLISP session didn't
  1824. succeed.
  1825.  
  1826. 90.3. The Language
  1827. ------------------
  1828.  
  1829. The language CLISP uses to communicate with the user can be either
  1830. ENGLISH or DEUTSCH (i.e. german) or FRANCAIS (i.e. french). The macros
  1831. ENGLISH, DEUTSCH, FRANCAIS and LANGUAGE-CASE produce code that depends on
  1832. the language:
  1833. (ENGLISH english-form DEUTSCH deutsch-form FRANCAIS francais-form)
  1834. - and all permutations of this - evaluates all of english-form, deutsch-form,
  1835. francais-form in no particular order and returns the evaluation result
  1836. corresponding to the user language.
  1837. (LANGUAGE-CASE {clause}*) executes the clause (analogous to CASE) that
  1838. corresponds to the user language.
  1839. The language itself is the value of
  1840. (ENGLISH 'ENGLISH DEUTSCH 'DEUTSCH FRANCAIS 'FRANCAIS).
  1841.  
  1842.  
  1843.                   CHAPTER 91: The Debugger and Stepper
  1844.                   ------------------------------------
  1845.  
  1846. The debugger may be invoked through the functions INVOKE-DEBUGGER, BREAK,
  1847. SIGNAL, ERROR, CERROR, WARN. The stepper is invoked through the macro STEP.
  1848. Debugger and stepper execute subordinate READ - EVAL - PRINT loops (called
  1849. "break loops") which are analogous to the main READ - EVAL - PRINT loop except
  1850. for the prompt and the set of available commands. Commands must be typed
  1851. literally, without surrounding quotes or white space.
  1852.  
  1853. Commands common to the main loop, the debugger and the stepper:
  1854.   Help       prints a list of available commands.
  1855.  
  1856. Commands common to the debugger and the stepper:
  1857.   Abort      and
  1858.   Unwind     abort to the next most recent READ - EVAL - PRINT loop.
  1859.  
  1860. The stack is organized into frames and other stack elements. Usually every
  1861. invocation of an interpreted function and every evaluation of an interpreted
  1862. form corresponds to one stack frame. Special forms such as LET, LET*,
  1863. UNWIND-PROTECT and CATCH produce special kinds of stack frames.
  1864.  
  1865. In a break loop there is a current stack frame, which is initially the most
  1866. recent stack frame but can be moved using the debugger commands Up and Down.
  1867.  
  1868. Evaluation of forms in a break loop occurs in the lexical environment of the
  1869. current stack frame but in the dynamic environment of the debugger's caller.
  1870. This means that to inspect or modify a lexical variable all you have to do
  1871. is to move to the current stack frame just below the frame that corresponds
  1872. to the form or the function call that binds that variable.
  1873.  
  1874. There is a current "stack mode" which defines in how much detail the stack
  1875. is shown by the stack related debugger commands.
  1876.  
  1877. Commands common to the debugger and the stepper:
  1878.   Mode-1      sets the current mode to 1: all the stack elements are
  1879.               considered. This mode is fine for debugging compiled functions.
  1880.   Mode-2      sets the current mode to 2: all the frames are considered.
  1881.   Mode-3      sets the current mode to 3: only lexical frames (frames that
  1882.               correspond to special forms that modify the lexical environment)
  1883.               are considered.
  1884.   Mode-4      sets the current mode to 4 (the default): only EVAL and APPLY
  1885.               frames are considered. Every evaluation of a form in the
  1886.               interpreter corresponds to an EVAL frame.
  1887.   Mode-5      sets the current mode to 5: only APPLY frames are considered.
  1888.               Every invocation of an interpreted function corresponds to one
  1889.               APPLY frame.
  1890.   Where       shows the current stack frame.
  1891.   Up          goes up one frame, i.e. to the caller if in mode-5
  1892.   Down        does down one frame, i.e. to the callee if in mode-5
  1893.   Top         goes to top frame, i.e. to the top-level form if in mode-4
  1894.   Bottom      goes to bottom (most recent) frame, i.e. most probably to the
  1895.               form or function that caused the debugger to be entered.
  1896.   Backtrace   lists the stack in current mode, bottom frame first, top frame
  1897.               last.
  1898.   Backtrace-1 lists the stack in mode 1.
  1899.   Backtrace-2 lists the stack in mode 2.
  1900.   Backtrace-3 lists the stack in mode 3.
  1901.   Backtrace-4 lists the stack in mode 4.
  1902.   Backtrace-5 lists the stack in mode 5.
  1903. If the current stack frame is an EVAL or APPLY frame, the following commands
  1904. are available as well:
  1905.   Break+      sets a breakpoint in the current frame. When the corresponding
  1906.               form or function will be left, the debugger will be entered
  1907.               again, with the variable *TRACE-VALUES* containing a list of
  1908.               its values.
  1909.   Break-      removes a breakpoint from the current frame.
  1910.   Redo        re-evaluates the corresponding form or function call. This
  1911.               command can be used to restart parts of a computation without
  1912.               aborting it entirely.
  1913.   Return      leaves the current frame. You will be prompted for the
  1914.               return values.
  1915.  
  1916. Commands specific to the debugger:
  1917.   Continue    continues evaluation of the program.
  1918.  
  1919. Commands specific to the stepper:
  1920.   Step        step into a form: evaluate this form in single step mode
  1921.   Next        step over a form: evaluate this form at once
  1922.   Over        step over this level: evaluate at once up to the next return
  1923.   Continue    switch off single step mode, continue evaluation
  1924.  
  1925. The stepper is usually used like this: If some form returns a strange value
  1926. or results in an error, call  (STEP form)  and navigate using the commands
  1927. Step  and  Next  until you reach the form you regard as responsible. If you
  1928. are too fast (execute Next once and get the error), there is no way back; you
  1929. have to restart the entire stepper session. If you are too slow (stepped into
  1930. a function or a form which certainly is OK), a couple of Next commands or one
  1931. Over command will help.
  1932.  
  1933.  
  1934. Authors:
  1935. --------
  1936.  
  1937.         Bruno Haible                    Michael Stoll
  1938.         Augartenstraße 40               Gallierweg 39
  1939.     D - 76137 Karlsruhe             D - 53117 Bonn
  1940.         Germany                         Germany
  1941.  
  1942. Email:  haible@ma2s2.mathematik.uni-karlsruhe.de
  1943.